<?php include("conexion.php");$sql="select COUNT(id) i from departamento;";echo $sql;$result=mysql_query($sql);$row = mysql_fetch_array($result);$cont=$row['i'];$i=1;$sql="select MAX(id) i from costo;";echo $sql;$result=mysql_query($sql);$row = mysql_fetch_array($result);$costo=$row['i'];while ($i<=$cont){	$monto=$_POST[$i];	if (empty($_POST[$i]))	$monto = 0;	$sql="insert into dep_cost (id_departamento,id_costo,monto) values ('".$i."','".$costo."',".$monto.");";	echo $sql;	$result=mysql_query($sql);	$i++;}echo "<script>location.href='costo_agregado.php'</script>";?>